<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet
	version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	
	<xsl:template match="response" mode="comments">
		<div id="comments_list" class="comments-list">
			<xsl:apply-templates />
			
			<div class="write-comment">
				<div class="header">Написать ответ</div>
				<form class="body" method="post" action="javascript:void(0);" onsubmit="Comment.post (0, 'message_reply', {@object-id}); return false;">
					<textarea rows="4" id="comment_text_0"/>
					<div class="error" id="comment_error_0" style="display: none;">Вы должны сначала написать ответ</div>
					<div class="buttons">
						<input type="submit" value="Ответить"/>
					</div>
				</form>
				
				<i class="corner-f8-10 tl"></i>
				<i class="corner-f8-10 tr"></i>
				<i class="corner-f8-10 br"></i>
				<i class="corner-f8-10 bl"></i>
			</div>
		</div>
	</xsl:template>
	
	<xsl:template match="object[@type='message_reply']">
		<xsl:param name="userAvatar" select="property[@name='user_avatar']/value" />
		<xsl:param name="userLogin" select="property[@name='user_login']/value" />
		
		<a name="comment{@id}" />
		<div class="item" id="comment_{@id}">
			<xsl:attribute name="style">
				<xsl:value-of select="concat ('margin-left: ', number(@comment-level) * 50, 'px')" />
			</xsl:attribute>
			
			<div class="avatar">
				<a href="{$baseURI}/user/{$userLogin}">
					<xsl:if test="$userAvatar = ''">
						<img src="{$baseURI}/images/default-user-avatar.png" alt="{$userLogin}" />
					</xsl:if>
					<xsl:if test="$userAvatar != ''">
						<img src="{$baseURI}/thumb_50_50{$userAvatar}" alt="{$userLogin}" />
					</xsl:if>
					
					<i class="corner-mask-white-5 tl"></i>
					<i class="corner-mask-white-5 tr"></i>
					<i class="corner-mask-white-5 br"></i>
					<i class="corner-mask-white-5 bl"></i>
				</a>
			</div>
			
			<div class="body">
				<div class="header">
					<a class="username" href="{$baseURI}/user/{$userLogin}">
						<xsl:value-of select="$userLogin" />
					</a>
					
					<span class="date">
						<xsl:value-of select="property[@name='pubdate']/value" />
					</span>
				</div>
				
				<div class="content">
					<xsl:value-of select="property[@name='text']/value" disable-output-escaping="yes" />
				</div>
				
				<xsl:if test="$userGroup != 'guest'">
					<div class="controls">
						<a href="#comment{@id}">ссылка</a>
						<a href="#" onclick="Comment.showForm ({@id}, '{../@type-name}', {../@object-id}); return false;">ответить</a>
					</div>
					<div class="reply" style="display:none;" id="new_comment_{@id}" />
				</xsl:if>
			</div>
		</div>
	</xsl:template>
	
</xsl:stylesheet>